package com.inspur.edp.rule.dsl.core.function;

import java.util.UUID;

/**
 * @author lizhaorui
 * @description TODO
 * @date 2024/12/31 11:30
 */
public class StringUtils {

    public static String subString(String str, int beginIndex, int length) {
        return org.apache.commons.lang3.StringUtils.substring(str, beginIndex, beginIndex + length);
    }

    public static int length(String str) {
        return org.apache.commons.lang3.StringUtils.length(str);
    }

    public static boolean equals(String str1, String str2) {
        return org.apache.commons.lang3.StringUtils.equals(str1, str2);
    }

    public static String concat(Object str1, Object str2) {
        StringBuilder sb = new StringBuilder();
        sb.append(str1);
        sb.append(str2);
        return sb.toString();
    }

    public static String concat3(Object str1, Object str2, Object str3) {
        StringBuilder sb = new StringBuilder();
        sb.append(str1);
        sb.append(str2);
        sb.append(str3);
        return sb.toString();
    }

    public static String concat4(Object str1, Object str2, Object str3, Object str4) {
        StringBuilder sb = new StringBuilder();
        sb.append(str1);
        sb.append(str2);
        sb.append(str3);
        sb.append(str4);
        return sb.toString();
    }

    public static String concat5(Object str1, Object str2, Object str3, Object str4, Object str5) {
        StringBuilder sb = new StringBuilder();
        sb.append(str1);
        sb.append(str2);
        sb.append(str3);
        sb.append(str4);
        sb.append(str5);
        return sb.toString();
    }

    public static boolean contains(String str, String target) {
        return org.apache.commons.lang3.StringUtils.contains(str, target);
    }

    public static boolean notContains(String str, String target) {
        return !str.contains(target);
    }

    public static boolean startWith(String str, String prefix) {
        return org.apache.commons.lang3.StringUtils.startsWith(str, prefix);
    }

    public static boolean notStartWith(String str, String prefix) {
        return !str.startsWith(prefix);
    }

    public static boolean endWith(String str, String suffix) {
        return org.apache.commons.lang3.StringUtils.endsWith(str, suffix);
    }

    public static boolean notEndWith(String str, String suffix) {
        return !str.endsWith(suffix);
    }

    public static String replace(String str, String target, String replacement) {
        return org.apache.commons.lang3.StringUtils.replace(str, target, replacement);
    }

    public static String toUpperCase(String str) {
        return org.apache.commons.lang3.StringUtils.upperCase(str);
    }

    public static String toLowerCase(String str) {
        return org.apache.commons.lang3.StringUtils.lowerCase(str);
    }

    public static int indexOf(String str, String target) {
        return org.apache.commons.lang3.StringUtils.indexOf(str, target);
    }

    public static int lastIndexOf(String str, String target) {
        return org.apache.commons.lang3.StringUtils.lastIndexOf(str, target);
    }

    public static String trim(String str) {
        return org.apache.commons.lang3.StringUtils.trim(str);
    }

    public static String createGuid() {
        return UUID.randomUUID().toString();
    }

    public static boolean isEmpty(String str) {
        return org.apache.commons.lang3.StringUtils.isEmpty(str);
    }

    public static boolean isNumStr(String str) {
        if (str == null) {
            return false;
        }
        try {
            Double.parseDouble(str);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }

}
